<%@ include file="/WEB-INF/template/include.jsp" %>

<openmrs:require privilege="View Labs" otherwise="/login.htm" redirect="/module/simplelabentry/resultEntry.htm" />

<spring:message var="pageTitle" code="simplelabentry.lab.manage" scope="page"/>

<%@ include file="/WEB-INF/template/header.jsp" %>

<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/moduleResources/simplelabentry/styles/paging.css" />
<script type="text/javascript"  src="${pageContext.request.contextPath}/moduleResources/simplelabentry/scripts/paging.js" ></script>
<openmrs:htmlInclude file="/moduleResources/simplelabentry/jquery-1.3.2.min.js" />
<h2><spring:message code="simplelabentry.lab.manage"/></h2>	

<br />
<c:forEach items="${errors.allErrors}" var="error">
	<span class="error"><spring:message code="${error.defaultMessage}" text="${error.defaultMessage}"/></span><
</c:forEach>
<input type="button" value="<spring:message code='simplelabentry.lab.add'/>" onclick="javascript:window.location.href='lab.form'"/>

<br /><br />
<c:choose>
<c:when test="${not empty listLab}">
<form method="post" onsubmit="return false" id="form">
<input type="button" onclick="checkValue()" value="<spring:message code='simplelabentry.lab.deleteselected'/>"/>
<span class="boxHeader"><spring:message code="simplelabentry.lab.list"/></span>
<div class="box">
<table cellpadding="5" cellspacing="0">
<tr>
	<th>#</th>
	<th><spring:message code="general.name"/></th>
	<th><spring:message code="simplelabentry.description"/></th>
	<th></th>
</tr>
<c:forEach items="${listLab}" var="lab" varStatus="varStatus">
	<tr class='${varStatus.index % 2 == 0 ? "oddRow" : "evenRow" } '>
		<td><c:out value="${varStatus.count}"/></td>	
		<td><a href="javascript:window.location.href='lab.form?labId=${lab.labId}'">${lab.name}</a> </td>
		<td>${lab.description}</td>
		<td><input type="checkbox" name="ids" value="${lab.labId}"/></td>
	</tr>
</c:forEach>
</form>
</table>
</div>
<script>
function checkValue()
{
	var form = jQuery("#form");
	if( jQuery("input[type='checkbox']:checked",form).length > 0 ) 
		form.submit();
	else{
		alert("Please choose items for deleting");
		return false;
	}
}</script>
</c:when>
<c:otherwise>
No lab found.
</c:otherwise>
</c:choose>

<%@ include file="/WEB-INF/template/footer.jsp" %>
